// JavaScript Document

function cmsUpdateRate(){
	
		var rating = $('.content-rater .content-rater-star-on').size();
		var total = $('.content-rater .content-rater-star').size();
		
		if(rating){	
			$('.content-rater-title').text(strings.rated + ": " + rating + "/" + total);
		}else{
			$('.content-rater-title').text(strings.notRated);
		}
}


$(function(){
		   
	$('.content-rater-star')
		.mouseenter(function(){  
			
			var index = $(this).text();
				
			$('.content-rater .content-rater-star').removeClass('content-rater-star-hot');
			
			for(var i = 1; i <= index; i++){
				$('.content-rater .content-rater-star:nth-child(' + i + ')').addClass('content-rater-star-hot');
			}
			
			$('.content-rater-title').text(strings.rate + " " + index);
			
		})
		.mouseleave(function(){  
			$('.content-rater .content-rater-star').removeClass('content-rater-star-hot');
			
			cmsUpdateRate();
		})
		.click(function(){  
			
			$('.content-rater-title').text(strings.ratingWait);
						
			$.post('/cms/rate.php', { idcontent: $('.content-rater-id').text(), rate: $('.content-rater .content-rater-star-hot').size() },
				   function(data){
					   $('.content-rater-title').text(strings.thanksForRating);
				   });
						
		})
		
		cmsUpdateRate();
		   
})